<--- %%NOBANNER%% --> _delmfun_.sas
 BackForward

/*-------------------<-- Start of Description-->---------------------\
| Delete a macro function, if exists;                                |
|---------------------<-- End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<-- Start of Files or Arguments Needed-->---------------|
| Argument:                                                          |
|    macrofunction: the names of functions to be deleted, separated  |
|                   by an empty space or a comma;                    |
|---------------<-- End of Files Arguments Needed-->-----------------|
|--------------------------------------------------------------------|
|------------------<-- Start of Files Created-->---------------------|
|  Example: %_delmfun_(prt,nobs);                                    |
|           %_delmfun_(%nrstr(%prt));                                |
\-------------------<-- End of Files Created-->---------------------*/
%macro _delmfun_ /parmbuff;
/*--------------------------------------------\
| Author:   Duo Zhou;                         |
| Created:  9-28-2001 9:12pm;                 |
| Modified: 1-15-2002 9:52pm;                 |
| Purpose:  Delete a macro function;          |
\--------------------------------------------*/
%local _nmacros_ imacro;
%let _nmacros_=0; 
%do %while(%length(%nrbquote(%qscan(%quote(&syspbuff), %eval(&_nmacros_+1), %str( (),)))));
	%let _nmacros_=%eval(&_nmacros_+1);
	%let macroname&_nmacros_=%qscan(%quote(&syspbuff), &_nmacros_, %str( (),));
%end;
%do imacro=1 %to &_nmacros_;
   %if (%length(&¯oname&imacro)>0) %then %do; 
      %if (%sysfunc (cexist(WORK.SASMACR.&¯oname&imacro...MACRO))) %then %do;
         proc catalog cat=WORK.SASMACR;
            delete &¯oname&imacro / et=macro;
         quit;
         %put ==> Alert! Deleting macro function %nrstr(%%)&¯oname&imacro from your system.;
      %end;
   %end;
%end;
%mend _delmfun_;